using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace FantastPlatform.Framework.Common
{
    public sealed class CollectionHelper
    {
        public static List<T> ToList<T>(params T[] values)
        {
            return new List<T>(values);
        }

        public static bool IsNullOrEmpty(ICollection collection)
        {
            if (collection != null)
            {
                return (collection.Count == 0);
            }
            return true;
        }

        public static bool IsNullOrEmpty<T>(ICollection<T> collection)
        {
            if (collection != null)
            {
                return (collection.Count == 0);
            }
            return true;
        }

        public static T[] ToArray<T>(IEnumerable<T> enumerable)
        {
            if (enumerable is T[])
                return (T[])enumerable;

            List<T> tempList = new List<T>(enumerable);
            return tempList.ToArray();
        }
    }
}
